home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Workbench Add-On
/
Workbench Add-On - Volume 1.iso
/
Dev
/
Oberon
/
source
/
Library
/
XYPlane.mod
< prev
Wrap
Text File
|
1995-06-29
|
3KB
|
117 lines
(*************************************************************************
$RCSfile: XYPlane.mod $
Description: Basic facilities for graphics programming.
Created by: fjc (Frank Copeland)
$Revision: 1.5 $
$Author: fjc $
$Date: 1995/06/04 23:22:41 $
Copyright © 1994-1995, Frank Copeland.
This file is part of the Oberon-A Library.
See Oberon-A.doc for conditions of use and distribution.
*************************************************************************)
<* STANDARD- *>
MODULE XYplane;
IMPORT
SYS := SYSTEM, Kernel, gfx := Graphics, i := Intuition,
as := AmigaSupport, InputPO;
CONST
draw *= 1;
erase *= 0;
VAR
X -, Y -, W -, H -: INTEGER;
CONST
drawPen = 1;
erasePen = 0;
PROCEDURE Open *;
BEGIN (* Open *)
IF as.scr = NIL THEN
as.OpenDisplay;
X := 0; Y := 0; W := as.W; H := as.H;
END
END Open;
PROCEDURE Clear *;
BEGIN (* Clear *)
as.BeginUpdate;
IF as.win # NIL THEN
gfx.SetRast (as.win.rPort, erasePen);
i.RefreshWindowFrame (as.win)
END;
as.EndUpdate
END Clear;
PROCEDURE Dot * ( x, y, mode : INTEGER );
VAR rp : gfx.RastPortPtr;
BEGIN (* Dot *)
ASSERT ((x >= 0) & (y >= 0) & ((mode = draw) OR (mode = erase)), 97);
as.BeginUpdate;
IF as.win # NIL THEN
(* Map Oberon co-ordinates to window co-ordinates *)
x := x + as.win.borderLeft;
y := as.win.height - as.win.borderBottom - y - 1;
(* Clip to window boundaries *)
IF (x < (as.win.width - as.win.borderRight)) & (y > as.win.borderTop) THEN
rp := as.win.rPort;
IF mode = draw THEN gfx.SetAPen (rp, drawPen)
ELSE gfx.SetAPen (rp, erasePen)
END;
gfx.SetDrMd (rp, gfx.jam1);
IF gfx.WritePixel (rp, x, y) THEN END;
END;
END;
as.EndUpdate
END Dot;
PROCEDURE IsDot * ( x, y : INTEGER ) : BOOLEAN;
VAR result : BOOLEAN;
BEGIN (* IsDot *)
ASSERT ((x >= 0) & (y >= 0), 97);
result := FALSE;
as.BeginUpdate;
IF as.win # NIL THEN
(* Map Oberon co-ordinates to window co-ordinates *)
x := x + as.win.borderLeft;
y := as.win.height - as.win.borderBottom - y - 1;
(* Clip to window boundaries *)
IF (x < (as.win.width - as.win.borderRight))
& (y > as.win.borderTop)
THEN
result := gfx.ReadPixel (as.win.rPort, x, y) # erasePen
END
END;
as.EndUpdate;
RETURN result
END IsDot;
PROCEDURE Key * () : CHAR;
VAR ch : CHAR;
BEGIN (* Key *)
InputPO.Read (ch);
RETURN ch
END Key;
END XYplane.